# -*- coding: utf-8 -*-#
#-------------------------------------------------------------------------------
# 建立者:        潘炎珍  
# Name:         hw01
# Description:
# Author:       98745
# Date:         2019/4/11
#-------------------------------------------------------------------------------

import random

class person:
    data=['红桃A','黑桃A','方块A','梅花A','红桃2','黑桃2','方块2','梅花2','红桃3','黑桃3','方块3','梅花3','红桃4','黑桃4','方块4','梅花4','红桃5','黑桃5','方块5','梅花5','红桃6','黑桃6','方块6','梅花6','红桃7','黑桃7','方块7','梅花7','红桃8','黑桃8','方块8','梅花8','红桃9','黑桃9','方块9','梅花9','红桃10','黑桃10','方块10','梅花10','红桃J','黑桃J','方块J','梅花J','红桃Q','黑桃Q','方块Q','梅花Q','红桃K','黑桃K','方块K','梅花K','小王','大王']
    #1号人选到的牌模板
    mode=['红桃A','黑桃A','方块A','梅花A','红桃2','黑桃2','方块2','梅花2','红桃Q','黑桃Q','方块Q','梅花Q','红桃K','黑桃K','方块K','梅花K','小王','大王','红桃J','黑桃J']


    def shuffle_data(self):#洗牌
        random.shuffle(self.data)


    def choice_data(self,code):#选牌
        try:
            count=0
            dict_data=[]
            while True:
                n = random.choice(self.data)
                if code==1:  #号人选的牌
                    if n in self.mode and count != 20:
                        dict_data.append(n)
                        self.data.remove(n)
                        count+=1
                    elif count==20:
                        break
                    else:
                        continue
                elif code==2:  #2号人选的牌
                    if count != 17:
                        dict_data.append(n)
                        self.data.remove(n)
                        count += 1
                    else:
                        break
                else:  #3号人选的牌
                    return self.data
            return dict_data
        except Exception as e:
            print(e)


    def get_info(self,code):#用一个函数调用洗牌和选牌函数，对象直接调用该函数
        try:
            self.shuffle_data()
            dict_data=self.choice_data(code)
            return dict_data
        except Exception as e:
            print(e)


if __name__=='__main__':
    person1=person()
    person2=person()
    person3=person()
    data1=person1.get_info(1)
    data2=person2.get_info(2)
    data3=person3.get_info(3)
    print('person1的牌是：{}'.format(data1))
    print('person2的牌是：{}'.format(data2))
    print('person3的牌是：{}'.format(data3))



